package demo12;

/**
 * Created with IntelliJ IDEA.
 * Description:多态的优点
 * User: 86183
 */
public class Test {
    public static void main(String[] args) {
        Cycle cycle = new Cycle();
        Flower flower = new Flower();
        Triangle triangle = new Triangle();
        Shape[] shapes = {cycle,flower,cycle,flower,triangle};
        for (Shape shape : shapes) {//向上转型
            shape.draw();
        }
       /* String[] shapes = {"cycle", "flower", "cycle", "flower"};
        for (String shape : shapes) {
            if (shape.equals("cycle")) {
                cycle.draw();
            }  else if (shape.equals("flower")) {
                flower.draw();
            }
        }*/
    }
}
